import { FormProps, FormSchema } from '@/components/Table'
import { BasicColumn } from '@/components/Table/src/types/table'
import { pattern } from '@/utils/validate/index'
import dayjs, { Dayjs } from 'dayjs'

// 用户列表
export function getUserBasicColumns(): BasicColumn[] {
  return [
    {
      title: '用户手机号',
      fixed: 'left',
      dataIndex: 'phoneNumber'
    },
    {
      title: '姓名',
      width: 100,
      customEllipsis: true,
      dataIndex: 'userName'
    },
    {
      title: '关联企业名称',
      width: 140,
      customEllipsis: true,
      dataIndex: 'enterpriseName'
    },
    {
      title: '关联企业税号',
      width: 120,
      dataIndex: 'taxNo'
    },
    {
      title: '计费类型',
      width: 80,
      dataIndex: 'chargeType'
    },
    {
      title: '付费类型',
      width: 80,
      dataIndex: 'payFlag'
    },
    {
      title: '有效期止',
      width: 140,
      dataIndex: 'endDate'
    },
    {
      title: '剩余Pai豆',
      align: 'right',
      width: 110,
      dataIndex: 'balanceScore'
    },
    {
      title: '所属渠道',
      width: 150,
      customEllipsis: true,
      dataIndex: 'channelName'
    },
    {
      title: '最近一次咨询时间',
      width: 140,
      dataIndex: 'lastChatTime'
    },
    {
      title: '创建时间',
      width: 140,
      dataIndex: 'createTime'
    },
    {
      title: '备注',
      width: 140,
      customEllipsis: true,
      dataIndex: 'userMark'
    },
    {
      title: '操作',
      width: 60,
      fixed: 'right',
      dataIndex: 'operate'
    }
  ]
}

export function getSearchFormConfig(): Partial<FormProps> {
  return {
    labelWidth: 120,
    baseColProps: {
      span: 6,
      md: 10,
      xl: 8,
      xxl: 6
    },
    schemas: [
      {
        field: 'phoneNumber',
        label: '用户手机号',
        component: 'Input'
      },
      {
        field: 'enterpriseName',
        label: '企业名称',
        component: 'Input'
      },
      {
        field: 'taxNo',
        label: '企业税号',
        component: 'Input'
      },
      {
        field: 'channelNoList',
        label: '所属渠道',
        component: 'TreeSelect',
        slot: 'channelCode'
      },
      {
        field: 'chargeType',
        label: '计费类型',
        component: 'Select',
        componentProps: {
          options: [
            {
              label: '周期计费',
              value: 'CYCLE',
              key: 'CYCLE'
            },
            {
              label: '次数计费',
              value: 'SCORE',
              key: 'SCORE'
            }
          ]
        }
      },
      {
        field: '[lastChatTimeBegin,lastChatTimeEnd]',
        label: '最近一次咨询时间',
        component: 'RangePicker',
        componentProps: {
          valueFormat: 'YYYY-MM-DD',
          disabledDate: (current: Dayjs) => {
            return current && current.isAfter(dayjs().startOf('day'), 'day')
          }
        }
      },
      {
        field: 'userMark',
        label: '备注',
        component: 'Input'
      }
    ]
  }
}
